//
//  MineViewController.m
//  ZYZB
//
//  Created by ENERGY on 2018/6/11.
//  Copyright © 2018年 ENERGY. All rights reserved.
//

#import "MineViewController.h"
#import "MineTopTableViewCell.h"
#import "MineBottomTableViewCell.h"
#import "LendPandectViewController.h"
#import "AccountInformationViewController.h"
#import "TradingRecordViewController.h"
#import "SafetyViewController.h"
#import "QuestionsViewController.h"
#import "BorrowViewController.h"
#import "RechargeViewController.h"
#import "WithdrawDepositViewController.h"
#import "MessageCenterViewController.h"
#import "SettingViewController.h"
#import "TestViewController.h"
#define tradeRecordBtnW 60/WIDTH_6_SCALE
@interface MineViewController ()<UINavigationControllerDelegate, UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong)UITableView * tableView;
@property (nonatomic, strong)UIView * headerView;
@property (nonatomic, strong)UIImageView * iconImg;//头像
@property (nonatomic, strong)UILabel * telLab;//手机号
@property (nonatomic, strong)UILabel * memberKindLab;//会员类型
@property (nonatomic, strong)UIButton * tradeRecordBtn;//交易记录
@property (nonatomic, strong)UILabel * propertyContentLab;//总资产数额
@property (nonatomic, strong)UILabel * bidMoneyContentLab;//投标金额
@property (nonatomic, strong)UILabel * forzeMoneyContentLab;//冻结金额
@property (nonatomic, strong)UILabel * earningsContentLab;//累计收益
@property (nonatomic, strong)UILabel * availableBalanceContentLab;//可用余额
@property (nonatomic, strong)NSMutableArray * cellTitleArr;
@property (nonatomic, strong)NSMutableArray * holdingLendCellArr;//持有中出借数额
@property (nonatomic, assign)int ifHaveOpenAccount;//0为未开户未绑卡，1为已开户已绑卡，2为已开户未绑卡
@end

@implementation MineViewController(networking)
//我的信息
- (void)mineDetailInformationData{
    [self showprogressHUD];
    NSString * timeStr = [self currentTimeStr];
    //str
    NSDictionary * dic = @{
                           @"userName":[UserModel sharedInstanced].mobile,
                           @"phone":[UserModel sharedInstanced].mobile,
                           @"token":[UserModel sharedInstanced].token,
                           @"t":timeStr
                           };
    //sign
    NSDictionary * signDic = @{
                               @"userName":[UserModel sharedInstanced].mobile,
                               @"phone":[UserModel sharedInstanced].mobile,
                               @"token":[UserModel sharedInstanced].token,
                               @"t":timeStr,
                               @"merchantNo":@"80d709a97af1b8ab"
                               };
    SortMD5Code * md5Code = [[SortMD5Code alloc] init];
    NSString * jsonStr = [md5Code getJsonWithStrDic:dic withSignDic:signDic];
    NSData *postData = [jsonStr dataUsingEncoding:NSUTF8StringEncoding];
    NSURL *url = [NSURL URLWithString:@"http://120.78.157.132:82/index.php/userInfo/index?api=api1001"];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    //设置请求方式
    request.HTTPMethod = @"POST";
    //设置请求参数
    request.HTTPBody = postData;
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
        [self hiddenProgressHUD];
        if (connectionError) {
            if (connectionError.code == -1001) {
                [self.view makeToast:@"请求网络超时，请稍后再试" duration:1 position:CSToastPositionCenter];
            }
        }else{
            NSDictionary *dictionary =[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];//data解析为dictionary
            if (!dictionary) {
                NSLog(@"数据缺失");
                return;
            }
            NSString * compareMD5Str = [md5Code encodeStringWithDictionary:dictionary];
            NSString * signResult = [dictionary objectForKey:@"sign"];//接到的json串sign字段
            NSDictionary * jsonData = [md5Code getNSDictionaryData:dictionary];//解析为字典数据
            
            if ([jsonData[@"code"] isEqualToString:@"000000"]) {
                if ([jsonData[@"body"] count] > 0) {
                    if ([compareMD5Str isEqualToString:signResult]) {
                        NSLog(@"成功");
                        NSDictionary * contentDic = jsonData[@"body"][0];
                        [self.iconImg sd_setImageWithURL:[NSURL URLWithString:contentDic[@"custImg"]] placeholderImage:[UIImage imageNamed:@"iconImg"]];
                        self.telLab.text = contentDic[@"phone"];
                        if ([contentDic[@"baijin"] isEqualToString:@"1"]) {
                            self.memberKindLab.text = @"白金会员";
                        }else{
                            self.memberKindLab.text = @"普通会员";
                        }
                        self.propertyContentLab.text = [NSString stringWithFormat:@"%@", contentDic[@"totalAmt"]];
                        self.bidMoneyContentLab.text = [NSString stringWithFormat:@"%@", contentDic[@"preLicAmt"]];
                        self.forzeMoneyContentLab.text = [NSString stringWithFormat:@"%@", contentDic[@"pledgedAmt"]];
                        self.earningsContentLab.text = [NSString stringWithFormat:@"%@", contentDic[@"cunIncome"]];
                        self.availableBalanceContentLab.text = [NSString stringWithFormat:@"%@", contentDic[@"actualAmt"]];
                        [self.holdingLendCellArr removeAllObjects];
                        [self.holdingLendCellArr addObjectsFromArray:jsonData[@"body"]];
                        self.ifHaveOpenAccount = [contentDic[@"k"] intValue];
                        [self.tableView reloadData];
                    }else{
                        NSLog(@"失败");
                        ShowMessage(jsonData[@"msg"]);
                    }
                }else{
                    ShowMessage(jsonData[@"msg"]);
                }
            }else{
//                ShowMessage(jsonData[@"msg"]);
            }
        }
    }];
}
//查询用户余额
- (void)balanceInquiryData{
    [self showprogressHUD];
    NSString * timeStr = [self currentTimeStr];
    //str
    NSDictionary * dic = @{
                           @"userName":[UserModel sharedInstanced].mobile,
                           @"t":timeStr,
                           @"token":[UserModel sharedInstanced].token,
                           @"phone":[UserModel sharedInstanced].mobile
                           };
    //sign
    NSDictionary * signDic = @{
                               @"userName":[UserModel sharedInstanced].mobile,
                               @"t":timeStr,
                               @"token":[UserModel sharedInstanced].token,
                               @"phone":[UserModel sharedInstanced].mobile,
                               @"merchantNo":@"80d709a97af1b8ab"
                               };
    SortMD5Code * md5Code = [[SortMD5Code alloc] init];
    NSString * jsonStr = [md5Code getJsonWithStrDic:dic withSignDic:signDic];
    NSData *postData = [jsonStr dataUsingEncoding:NSUTF8StringEncoding];
    NSURL *url = [NSURL URLWithString:@"http://120.78.157.132:82/index.php/userCent/find"];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    //设置请求方式
    request.HTTPMethod = @"POST";
    //设置请求参数
    request.HTTPBody = postData;
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
        [self hiddenProgressHUD];
        if (connectionError) {
            if (connectionError.code == -1001) {
                [self.view makeToast:@"请求网络超时，请稍后再试" duration:1 position:CSToastPositionCenter];
            }
        }else{
            NSDictionary *dictionary =[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];//data解析为dictionary
            if (!dictionary) {
                NSLog(@"数据缺失");
                return;
            }
//            NSString * compareMD5Str = [md5Code encodeStringWithDictionary:dictionary];
//            NSString * signResult = [dictionary objectForKey:@"sign"];//接到的json串sign字段
            NSDictionary * jsonData = [md5Code getNSDictionaryData:dictionary];//解析为字典数据
            
            if ([jsonData[@"code"] isEqualToString:@"000000"]) {
                if ([jsonData[@"body"] count] > 0) {
//                    if ([compareMD5Str isEqualToString:signResult]) {
                        NSLog(@"成功");
                        self.availableBalanceContentLab.text = [NSString stringWithFormat:@"%@", jsonData[@"body"][@"actualAmt"]];//可用余额
//                        NSString * acctStatus = [NSString stringWithFormat:@"%@", jsonData[@"body"][@"acctStatus"]];//账户状态，判断是否冻结
                        self.forzeMoneyContentLab.text = [NSString stringWithFormat:@"%@", jsonData[@"body"][@"pledgedAmt"]];//冻结金额
                        self.propertyContentLab.text = [NSString stringWithFormat:@"%@", jsonData[@"body"][@"totalAmt"]];//总金额
                        self.bidMoneyContentLab.text = [NSString stringWithFormat:@"%@", jsonData[@"body"][@"preLicAmt"]];//总金额
//                    }else{
//                        NSLog(@"失败");
//                        ShowMessage(jsonData[@"msg"]);
//                    }
                }else{
                    ShowMessage(jsonData[@"msg"]);
                }
            }else{
                ShowMessage(jsonData[@"msg"]);
            }
        }
    }];
}
@end

@implementation MineViewController

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.delegate = self;
    [self setStatusBarBackgroundColor:[UIColor whiteColor]];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    
//    [self mineDetailInformationData];//我的信息
//    [self balanceInquiryData];//查询用户账户余额
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}
- (UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleDefault;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"";
    self.view.backgroundColor = [UIColor whiteColor];
    if (@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    [self.view addSubview:self.tableView];
}

#pragma mark - UINavigationControllerDelegate
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
    BOOL isHomePage = [viewController isKindOfClass:[self class]];
    [self.navigationController setNavigationBarHidden:isHomePage animated:YES];
}
//#pragma mark - UINavigationControllerDelegate
//- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
//    BOOL isHomePage = [viewController isKindOfClass:[self class]];
//    [self.navigationController setNavigationBarHidden:isHomePage animated:YES];
//}

#pragma mark - init
- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - TABBAR_HEIGHT) style:UITableViewStylePlain];
        _tableView.tableHeaderView = self.headerView;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_tableView registerClass:[MineBottomTableViewCell class] forCellReuseIdentifier:NSStringFromClass([MineBottomTableViewCell class])];
        [_tableView registerClass:[MineTopTableViewCell class] forCellReuseIdentifier:NSStringFromClass([MineTopTableViewCell class])];
        _tableView.backgroundColor = [UIColor whiteColor];
    }return _tableView;
}
- (UIView *)headerView{
    if (!_headerView) {
        _headerView = [[UIView alloc] init];
        if (Is_Iphone_X) {
            _headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 348/WIDTH_6_SCALE + 24);
        }else{
            _headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 348/WIDTH_6_SCALE);
        }
        [self setUpHeaderViews];
//        self.headerView.backgroundColor = [UIColor redColor];
    }return _headerView;
}
- (void)setUpHeaderViews{
    //头像
    int iconImgW = 30/WIDTH_6_SCALE;
    self.iconImg = [[UIImageView alloc] init];
    if (Is_Iphone_X) {
        self.iconImg.frame = CGRectMake(18/WIDTH_6_SCALE, 27/WIDTH_6_SCALE + 24, iconImgW, iconImgW);
    }else{
        self.iconImg.frame = CGRectMake(18/WIDTH_6_SCALE, 27/WIDTH_6_SCALE, iconImgW, iconImgW);
    }
    self.iconImg.layer.cornerRadius = iconImgW/2;
    self.iconImg.layer.masksToBounds = YES;
    self.iconImg.image = [UIImage imageNamed:@"iconImg"];
    [_headerView addSubview:self.iconImg];
    //手机号
    self.telLab = [[UILabel alloc] initWithFrame:CGRectMake(self.iconImg.right + 10/WIDTH_6_SCALE, 0, 95/WIDTH_6_SCALE, 12/WIDTH_6_SCALE)];
    self.telLab.centerY = self.iconImg.centerY;
    [self label:self.telLab withFont:DEF_FontSize_12 withText:@"" withTextColor:[UIColor blackColor] withTextAlignment:NSTextAlignmentLeft withView:_headerView];
    self.telLab.userInteractionEnabled = YES;
    UITapGestureRecognizer * accountTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(accountPageClick)];
    [self.telLab addGestureRecognizer:accountTap];
    //会员类型
    self.memberKindLab = [[UILabel alloc] initWithFrame:CGRectMake(self.telLab.right + 0/WIDTH_6_SCALE, self.telLab.top, 50/WIDTH_6_SCALE, self.telLab.height)];
    self.memberKindLab.centerY = self.telLab.centerY;
    [self label:self.memberKindLab withFont:DEF_FontSize_10 withText:@"" withTextColor:getColor(@"3675bd") withTextAlignment:NSTextAlignmentLeft withView:_headerView];
    //客服
    int btnW = 20/WIDTH_6_SCALE;
    UIButton * serviceBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 84/WIDTH_6_SCALE, 0, btnW, btnW)];
    serviceBtn.centerY = self.iconImg.centerY;
    [serviceBtn addTarget:self action:@selector(serviceBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [serviceBtn setImage:[UIImage imageNamed:@"serve"] forState:UIControlStateNormal];
    [_headerView addSubview:serviceBtn];
    //消息
    UIButton * messageBtn = [[UIButton alloc] initWithFrame:CGRectMake(serviceBtn.right + 28/WIDTH_6_SCALE, serviceBtn.top, btnW, btnW)];
    [messageBtn setImage:[UIImage imageNamed:@"message"] forState:UIControlStateNormal];
    [messageBtn addTarget:self action:@selector(messageBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [_headerView addSubview:messageBtn];
    //蓝色背景
    UIView * blueView = [[UIView alloc] initWithFrame:CGRectMake(18/WIDTH_6_SCALE, self.iconImg.bottom + 11/WIDTH_6_SCALE, SCREEN_WIDTH - 36/WIDTH_6_SCALE, 170/WIDTH_6_SCALE)];
    blueView.backgroundColor = getColor(@"3675bd");
    blueView.layer.cornerRadius = 6;
    blueView.layer.masksToBounds = YES;
    [_headerView addSubview:blueView];
    //总资产标题
    UILabel * propertyTitleLab = [[UILabel alloc] initWithFrame:CGRectMake(22/WIDTH_6_SCALE, 22/WIDTH_6_SCALE, 70/WIDTH_6_SCALE, 13/WIDTH_6_SCALE)];
    [self label:propertyTitleLab withFont:DEF_FontSize_12 withText:@"总资产(元)" withTextColor:[UIColor whiteColor] withTextAlignment:NSTextAlignmentLeft withView:blueView];
    //是否明文显示
    UIButton * clearDisplayBtn = [[UIButton alloc] initWithFrame:CGRectMake(propertyTitleLab.right + 15/WIDTH_6_SCALE, 0, 20/WIDTH_6_SCALE, 15/WIDTH_6_SCALE)];
    clearDisplayBtn.centerY = propertyTitleLab.centerY;
    [clearDisplayBtn setImage:[UIImage imageNamed:@"eye"] forState:UIControlStateNormal];
    [blueView addSubview:clearDisplayBtn];
    //交易记录
    self.tradeRecordBtn = [[UIButton alloc] initWithFrame:CGRectMake(blueView.width - tradeRecordBtnW - 22/WIDTH_6_SCALE, 0, tradeRecordBtnW, 12/WIDTH_6_SCALE)];
    [blueView addSubview:self.tradeRecordBtn];
    self.tradeRecordBtn.centerY = propertyTitleLab.centerY;
    [self.tradeRecordBtn setTitle:@" 交易记录" forState:UIControlStateNormal];
    [self.tradeRecordBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.tradeRecordBtn setImage:[UIImage imageNamed:@"trade"] forState:UIControlStateNormal];
    self.tradeRecordBtn.titleLabel.font = DEF_FontSize_10;
    [self.tradeRecordBtn addTarget:self action:@selector(tradeRecordBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    //总资产数额
    self.propertyContentLab = [[UILabel alloc] initWithFrame:CGRectMake(propertyTitleLab.left, propertyTitleLab.bottom + 14/WIDTH_6_SCALE, SCREEN_WIDTH - 44/WIDTH_6_SCALE, 24/WIDTH_6_SCALE)];
    [self label:self.propertyContentLab withFont:[UIFont systemFontOfSize:24] withText:@"0.00" withTextColor:[UIColor whiteColor] withTextAlignment:NSTextAlignmentLeft withView:blueView];
    //分割线
    UIView * lineView = [[UIView alloc] initWithFrame:CGRectMake(22/WIDTH_6_SCALE, self.propertyContentLab.bottom + 38/WIDTH_6_SCALE, SCREEN_WIDTH - 44/WIDTH_6_SCALE, 1/WIDTH_6_SCALE)];
    lineView.backgroundColor = getColor(@"5e91ca");
    [blueView addSubview:lineView];
    //投标金额标题
    int numLabW = blueView.width/3;
    UILabel * bidMoneyTitleLab = [[UILabel alloc] initWithFrame:CGRectMake(0, lineView.bottom + 16/WIDTH_6_SCALE, numLabW, 11/WIDTH_6_SCALE)];
    [self label:bidMoneyTitleLab withFont:DEF_FontSize_10 withText:@"投标金额(元)" withTextColor:getColor(@"c1d0e7") withTextAlignment:NSTextAlignmentCenter withView:blueView];
    //冻结金额标题
    UILabel * forzeMoneyTitleLab = [[UILabel alloc] initWithFrame:CGRectMake(bidMoneyTitleLab.right, bidMoneyTitleLab.top, bidMoneyTitleLab.width, bidMoneyTitleLab.height)];
    [self label:forzeMoneyTitleLab withFont:DEF_FontSize_10 withText:@"冻结金额(元)" withTextColor:getColor(@"c1d0e7") withTextAlignment:NSTextAlignmentCenter withView:blueView];
    //累计收益标题
    UILabel * earningsContentLab = [[UILabel alloc] initWithFrame:CGRectMake(forzeMoneyTitleLab.right, bidMoneyTitleLab.top, bidMoneyTitleLab.width, bidMoneyTitleLab.height)];
    [self label:earningsContentLab withFont:DEF_FontSize_10 withText:@"累计收益(元)" withTextColor:getColor(@"c1d0e7") withTextAlignment:NSTextAlignmentCenter withView:blueView];
    //投标金额内容
    self.bidMoneyContentLab = [[UILabel alloc] initWithFrame:CGRectMake(0, bidMoneyTitleLab.bottom + 9/WIDTH_6_SCALE, numLabW, 11/WIDTH_6_SCALE)];
    [self label:self.bidMoneyContentLab withFont:DEF_FontSize_10 withText:@"0" withTextColor:getColor(@"c1d0e7") withTextAlignment:NSTextAlignmentCenter withView:blueView];
    //冻结金额内容
    self.forzeMoneyContentLab = [[UILabel alloc] initWithFrame:CGRectMake(forzeMoneyTitleLab.left, self.bidMoneyContentLab.top, self.bidMoneyContentLab.width, self.bidMoneyContentLab.height)];
    [self label:self.forzeMoneyContentLab withFont:DEF_FontSize_10 withText:@"0" withTextColor:getColor(@"c1d0e7") withTextAlignment:NSTextAlignmentCenter withView:blueView];
    //累计收益内容
    self.earningsContentLab = [[UILabel alloc] initWithFrame:CGRectMake(earningsContentLab.left, self.bidMoneyContentLab.top, self.bidMoneyContentLab.width, self.bidMoneyContentLab.height)];
    [self label:self.earningsContentLab withFont:DEF_FontSize_10 withText:@"0" withTextColor:getColor(@"c1d0e7") withTextAlignment:NSTextAlignmentCenter withView:blueView];
    //分割线
    UIView * upBorderLineView = [[UIView alloc] initWithFrame:CGRectMake(0, blueView.bottom + 14/WIDTH_6_SCALE, SCREEN_WIDTH, 1/WIDTH_6_SCALE)];
    upBorderLineView.backgroundColor = getColor(grayColor);
    [_headerView addSubview:upBorderLineView];
    //间隔
    UIView * sectionView = [[UIView alloc] initWithFrame:CGRectMake(0, upBorderLineView.bottom, SCREEN_WIDTH, 13/WIDTH_6_SCALE)];
    sectionView.backgroundColor = getColor(grayBGColor);
    [_headerView addSubview:sectionView];
    //分割线
    UIView * downBorderLineView = [[UIView alloc] initWithFrame:CGRectMake(0, sectionView.bottom, SCREEN_WIDTH, 1/WIDTH_6_SCALE)];
    downBorderLineView.backgroundColor = getColor(grayColor);
    [_headerView addSubview:downBorderLineView];
    //可用余额标题
    UILabel * availableBalanceTitleLab = [[UILabel alloc] initWithFrame:CGRectMake(17/WIDTH_6_SCALE, downBorderLineView.bottom + 22/WIDTH_6_SCALE, 100/WIDTH_6_SCALE, 11/WIDTH_6_SCALE)];
    availableBalanceTitleLab.text = @"可用余额(元)";
    availableBalanceTitleLab.font = DEF_FontSize_10;
    [_headerView addSubview:availableBalanceTitleLab];
    //可用余额内容
    self.availableBalanceContentLab = [[UILabel alloc] initWithFrame:CGRectMake(availableBalanceTitleLab.left, availableBalanceTitleLab.bottom + 10/WIDTH_6_SCALE, 215/WIDTH_6_SCALE, 18/WIDTH_6_SCALE)];
    self.availableBalanceContentLab.font = DEF_FontSize_18;
    self.availableBalanceContentLab.textColor = getColor(@"ff8819");
    self.availableBalanceContentLab.text = @"";
    [_headerView addSubview:self.availableBalanceContentLab];
    //充值
    int functionBtnW = 49/WIDTH_6_SCALE;
    int functionBtnH = 26/WIDTH_6_SCALE;
    UIButton * rechargeBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 136/WIDTH_6_SCALE, downBorderLineView.bottom + 30/WIDTH_6_SCALE, functionBtnW, functionBtnH)];
    [self button:rechargeBtn withBGColor:[UIColor clearColor] withLayerBorderColor:[UIColor orangeColor] withLayerBorderWith:1 withCornerRadius:6 withMasksToBounds:YES withViwe:_headerView];
    [rechargeBtn setTitle:@"充值" forState:UIControlStateNormal];
    [rechargeBtn addTarget:self action:@selector(rechargeBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [rechargeBtn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    //提现
    UIButton * withdrawDepositBtn = [[UIButton alloc] initWithFrame:CGRectMake(rechargeBtn.right + 20/WIDTH_6_SCALE, rechargeBtn.top, rechargeBtn.width, rechargeBtn.height)];
    [self button:withdrawDepositBtn withBGColor:[UIColor clearColor] withLayerBorderColor:[UIColor orangeColor] withLayerBorderWith:1 withCornerRadius:6 withMasksToBounds:YES withViwe:_headerView];
    [withdrawDepositBtn setTitle:@"提现" forState:UIControlStateNormal];
    [withdrawDepositBtn addTarget:self action:@selector(withdrawDepositBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    [withdrawDepositBtn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    //    //分割线
    //    UIView * bottomBorderLine = [[UIView alloc] initWithFrame:CGRectMake(18/WIDTH_6_SCALE, _headerView.bottom - 1/WIDTH_6_SCALE, SCREEN_WIDTH - 36/WIDTH_6_SCALE, 1/WIDTH_6_SCALE)];
    //    bottomBorderLine.backgroundColor = getColor(grayColor);
    //    [_headerView addSubview:bottomBorderLine];
}
- (NSMutableArray *)cellTitleArr{
    if (!_cellTitleArr) {
        _cellTitleArr = @[@{@"title":@"安全保障"},
                          @{@"title":@"常见问题"},
                          @{@"title":@"我要借款"},
                          @{@"title":@"设置"}].mutableCopy;
    }return _cellTitleArr;
}
- (NSMutableArray *)holdingLendCellArr{
    if (!_holdingLendCellArr) {
        _holdingLendCellArr = @[].mutableCopy;
    }return _holdingLendCellArr;
}
#pragma mark - tableViewDelegate和tableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.cellTitleArr.count + 1;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * cell = nil;
    if (indexPath.row == 0) {
        MineTopTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([MineTopTableViewCell class]) forIndexPath:indexPath];
        if (self.holdingLendCellArr.count != 0) {
            cell.model = self.holdingLendCellArr[indexPath.row];
        }
        return cell;
    }else{
        MineBottomTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([MineBottomTableViewCell class]) forIndexPath:indexPath];
        cell.model = self.cellTitleArr[indexPath.row - 1];
        return cell;
    }
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 56/WIDTH_6_SCALE;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 1) {
        SafetyViewController * safetyVC = [[SafetyViewController alloc] init];
        safetyVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:safetyVC animated:YES];
    }else if (indexPath.row == 2){
        QuestionsViewController * questionsVC = [[QuestionsViewController alloc] init];
        questionsVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:questionsVC animated:YES];
    }else if (indexPath.row == 3){
        BorrowViewController * borrowVC = [[BorrowViewController alloc] init];
        borrowVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:borrowVC animated:YES];
    }else if (indexPath.row == 4){
        SettingViewController * settingVC = [[SettingViewController alloc] init];
        settingVC.hidesBottomBarWhenPushed = YES;
        settingVC.ifHaveOpenAccount = self.ifHaveOpenAccount;
        [self.navigationController pushViewController:settingVC animated:YES];
//        TestViewController * lendPandectVC = [[TestViewController alloc] init];
//        lendPandectVC.hidesBottomBarWhenPushed = YES;
//        [self.navigationController pushViewController:lendPandectVC animated:YES];
    }else{
        LendPandectViewController * lendPandectVC = [[LendPandectViewController alloc] init];
        lendPandectVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:lendPandectVC animated:YES];
    }
    //    TestViewController * lendPandectVC = [[TestViewController alloc] init];
    //    lendPandectVC.hidesBottomBarWhenPushed = YES;
    //    [self.navigationController pushViewController:lendPandectVC animated:YES];
    
}
#pragma mark - action
- (void)accountPageClick{
    AccountInformationViewController * vc = [[AccountInformationViewController alloc] init];
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)tradeRecordBtnClick:(UIButton *)sender{
    TradingRecordViewController * vc = [[TradingRecordViewController alloc] init];
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)rechargeBtnClick:(UIButton *)sender{//充值
    RechargeViewController * rechargeVC = [[RechargeViewController alloc] init];
    rechargeVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:rechargeVC animated:YES];
}
- (void)withdrawDepositBtnClick:(UIButton *)sender{//提现
    WithdrawDepositViewController * withdrawDepositVC = [[WithdrawDepositViewController alloc] init];
    withdrawDepositVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:withdrawDepositVC animated:YES];
}
- (void)serviceBtnClick:(UIButton *)sender{
    NSLog(@"客服");
}
- (void)messageBtnClick:(UIButton *)sender{
    NSLog(@"消息中心");
    MessageCenterViewController * messageCenter = [[MessageCenterViewController alloc] init];
    messageCenter.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:messageCenter animated:YES];
}
@end
